package com.wsm.consumer.business;

import com.wsm.api.serivce.ApiService;
import com.wsm.common.dto.request.DtoRequest;
import com.wsm.common.dto.response.DtoResponse;
import com.wsm.common.utils.StringUtils;
import com.wsm.consumer.feign.FeignApiService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：wangshimin
 * @date ：Created in 2020-10-31 下午 12:47
 * @description：消费者业务层
 * @version:
 */
@Service
public class ConsumerBiz {

    @Resource
    FeignApiService feignApiService;

    @DubboReference
    ApiService apiService;

    public DtoResponse getTestByFeign(DtoRequest dtoRequest) throws Exception {
        if (dtoRequest == null || StringUtils.isEmpty(dtoRequest.getRequest())) {
            throw new Exception("不允许为空");
        }
        return feignApiService.getTest(dtoRequest);
    }

    public DtoResponse getTestByDubbo(DtoRequest dtoRequest) {
        return apiService.getTest(dtoRequest);
    }
}
